package com.ssy.lingxi.member.merchant.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.DropdownItem;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 会员考察类型
 * @author yzc
 * @version 2.0.0
 * @date 2021/5/17
 */

public enum MemberInspectTypeEnum {
    /**
     * 入库考察 - 1
     */
    deposit(1, "入库考察"),

    /**
     * 整改考察 - 2
     */
    rectify(2, "整改考察"),

    /**
     * 计划考察 - 3
     */
    plan(3, "计划考察"),

    /**
     * 其他考察 - 4
     */
    other(4, "其他考察");

    MemberInspectTypeEnum(Integer code, String message) {
        this.code = code;
    }

    private final Integer code;

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }

    public static String getMsgByCode(Integer code) {
        return LanguageHolder.getName(MemberInspectTypeEnum.class, code);
    }

    public static List<DropdownItem> toDropdownItems() {
        return Arrays.stream(MemberInspectTypeEnum.values()).sorted(Comparator.comparingInt(MemberInspectTypeEnum::getCode)).map(e -> new DropdownItem(e.getCode(), e.getMessage())).collect(Collectors.toList());
    }
}
